INI : INI parser and encoder
This module is an INI
format parsing module, similar to the JavaScript built-in JSON
object.
This module has been built-in in JSRE and does not require require()
to import.
Example
var fs = require('fs');
var obj = {
section1: {
key1: '111'
},
section2: {
key1: '1111',
key2: '2222'
}
};
var str = INI.stringify(obj);
fs.writeFile('./test.ini', str);
var fs = require('fs');
var str = fs.readString('./test.ini');
var obj = INI.parse(str);
console.log('ini obj:', obj);
Support
The following shows INI
module APIs available for each permissions.
User Mode | Privilege Mode | |
---|---|---|
INI.parse | ● | ● |
INI.stringify | ● | ● |
INI Object
INI.parse(iniString)
iniString
{String} INI format string.- Returns: {Object} Convert to object.
Parse the specified INI string and return the result object.
Similar to JSON.parse()
.
INI.stringify(obj[, replacer[, space]])
obj
{Object} Object to be convert.replacer
{Function} | {Array} Unsupport now.space
{String} Add indents spaces. default: ''.- Returns: {String} INI format string.
Convert specified object to INI format string. space
can be: ''
, ' '
, '\t'
.
Similar to JSON.stringify()
.